#include "door.h"
#include "beep.h"
#include "nb_lock.h"

#define DOOR_DELAY_CLOSE_TIME (10000)

door_info_t door_info = {
  .flag = 0,
  .time = 0,
};


void door_task(void)
{
  if(door_info.flag==1)
  {
    beep_control(500,2000,25);
    door_open();
    door_info.flag = 2;
    door_info.time = getSystemTime();
  }
  else if(door_info.flag==2)
  {
    if((getSystemTime()-door_info.time)>DOOR_DELAY_CLOSE_TIME)
    {
      door_close();
      door_info.flag=0;
    }
  }
}